package hms.inventory;

/**
 * ItemCategory is a classification of Inventory Items.
 * 
 * @author Akilah McIntyre
 */
public class ItemCategory {
	/**
	 * unique identifier of an item category
	 */
	public int itemCategory_id = -1;
	/**
	 * name of an item category
	 */
	public String itemCategory_name = "";

	/**
	 * Constructs an item category from an unique identifier and a name.
	 * 
	 * @param itemCategoryID
	 *            unique identifier of an item category
	 * @param itemCategoryName
	 *            name of of an item category
	 * 
	 **/
	public ItemCategory(int itemCategoryID, String itemCategoryName) {
		this.itemCategory_id = itemCategoryID;
		this.itemCategory_name = itemCategoryName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + itemCategory_id;
		result = prime
				* result
				+ ((itemCategory_name == null) ? 0 : itemCategory_name
						.hashCode());
		return result;
	}

	/**
	 * Compares two item categories for equality. The result is true if and only
	 * if the argument is not null and is an ItemCategory object has the same
	 * unique identifier and name as this object.
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof ItemCategory)) {
			return false;
		}
		ItemCategory other = (ItemCategory) obj;
		if (itemCategory_id != other.itemCategory_id) {
			return false;
		}
		if (itemCategory_name == null) {
			if (other.itemCategory_name != null) {
				return false;
			}
		} else if (!itemCategory_name.equals(other.itemCategory_name)) {
			return false;
		}
		return true;
	}

	/**
	 * Returns a string representation of this ItemCategory, which is
	 * itemCategory_name
	 **/
	public String toString() {
		return itemCategory_name;
	}

}